package com.tasogo.comm;

import android.content.Context;
import android.hardware.ConsumerIrManager;
import android.util.Log;
import com.SunSoft.PhoneRemoteControl.MainControl;

public final class b
  implements e
{
  private ConsumerIrManager a;

  public b()
  {
    try
    {
      this.a = ((ConsumerIrManager)MainControl.i().getSystemService("consumer_ir"));
      if (this.a == null)
      {
        a("irda", "IR service is null");
        if (!(this.a.hasIrEmitter()))
          return;
        a("irda", "find IR device");
        return;
      }
      a("irda", "get IR service");
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private static void a(String paramString1, String paramString2)
  {
    if (!(MainControl.e))
      return;
    Log.d(paramString1, paramString2);
  }

  public final boolean a(String paramString, int paramInt)
  {
    while (true)
    {
      int i;
      try
      {
        if (this.a != null)
          if (this.a.hasIrEmitter())
          {
            paramString = paramString.trim().split(",");
            if ((paramString != null) && (paramString.length > 3))
            {
              int[] arrayOfInt = new int[paramString.length - 1];
              int j = Integer.valueOf(paramString[0]).intValue();
              int k = (int)(1000000 / j + 0.5F);
              i = 1;
              if (i >= paramString.length)
              {
                this.a.transmit(j, arrayOfInt);
                a("irda", "android send OK");
                return true;
              }
              if (paramInt == 0)
              {
                arrayOfInt[(i - 1)] = Integer.valueOf(paramString[i]).intValue();
                break label149:
              }
              arrayOfInt[(i - 1)] = (Integer.valueOf(paramString[i]).intValue() * k);
              break label149:
            }
            return false;
          }
        return false;
      }
      catch (Exception paramString)
      {
        return false;
      }
      label149: i += 1;
    }
  }
}